package cn.italkcloud.cph.constants.enums.vos;

import lombok.Getter;

import java.util.Objects;

/**
 * @author dominate
 * @since 2024/7/9
 **/
@Getter
public enum FeeLogTypeEnum {
    ALL(-1, "全部"),
    RECHARGE(0, "手动充值/扣费"),
    CONSUME(1, "自动消耗");

    final int code;
    final String name;

    FeeLogTypeEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }


    public static FeeLogTypeEnum getValueByCode(Integer code) {
        if (Objects.isNull(code)) {
            return ALL;
        }
        return getValueByCode((int) code);
    }

    public static FeeLogTypeEnum getValueByCode(int code) {
        for (FeeLogTypeEnum value : FeeLogTypeEnum.values()) {
            if (code == value.getCode()) {
                return value;
            }
        }
        return ALL;
    }

    public static String getName(int code) {
        return getValueByCode(code).getName();
    }
}
